package test;

import com.sun.org.apache.regexp.internal.RE;

//单例模式
public class OneInstance {
//    static private OneInstance oneInstance=new OneInstance();
//    private OneInstance(){
//
//    }
//    public static OneInstance getInstance(){
//        return oneInstance;
//    }
    static OneInstance oneInstance=null;
    private OneInstance(){

    }
    public static OneInstance getInstance(){
        if(oneInstance==null){
            oneInstance=new OneInstance();
        }
        return oneInstance;
    }
}
class Test{
    public static void main(String[] args) {
        OneInstance oneInstance1=OneInstance.getInstance();
        OneInstance oneInstance2=OneInstance.getInstance();
        System.out.println(oneInstance1==oneInstance2);
    }
}
